#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
@File Name  : backup_to_uFile.py
@Author     : LeeCQ
@Date-Time  : 2019/12/8 15:48

备份文件到 U-File.cn

"""

class BackupUFile:
    """
    备份文件到U-File.cn
    """
    WinSCP_PATH = r'"C:\Program Files (x86)\WinSCP\WinSCP.exe"'
    SessionURL = "ftp://leecq%2Fufile-test:Fp1ta0JPi9hFgBtNgd6J2wnS0VLL08IP@box.u-file.cn/"

    def __init__(self):
        self.ini_path = './'
        self.log_path = r'D:\Robocopy\WinSCP_py_u-file.log'
        self.log_level = 0
        self.synchronization_dir = []

    def set_logLevel(self, level=0):
        self.log_level = level


class BackupUFileSynchronize(BackupUFile):
    def __synchronize_dir(self):
        try:
            with open(self.ini_path + '/u-file.ini', 'r', encoding='utf8') as f:
                return [x.split('\t') for x in f.read().split('\n') if x.find('\t') > 0]
        except:
            return []

    def set_synchronization_dir(self, src_dir, target_dir):
        self.synchronization_dir.append((src_dir, target_dir))

